<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>索引问题</title>
<script type="text/javascript">
	
	window.onload = function() {
		// 获取所有超链接
		var allA = document.getElementsByTagName("a");
		
		// 为每个超链接都绑定一个单击响应函数
		for(var i = 0 ; i< allA.length ; i++) {

			// for循环在页面加载完之后，立即执行
			// 当响应函数执行时，for循环早已执行完毕，i的值变成了3
			allA[i].onclick = function() {
				// 注意理解  this.和allA[i]是不等效的
				console.log(i);
				console.log(allA[i]); // undefined
				return false;
			};
			
		}
		
	};

	
</script>
</head>
<body>

	<table id="employeeTable">
		<tr>
			<th>Name</th>
			<th>Email</th>
			<th>Salary</th>
			<th>&nbsp;</th>
		</tr>
		<tr>
			<td>Tom</td>
			<td>tom@tom.com</td>
			<td>5000</td>
			<td><a href="javascript:;">Delete</a></td>
		</tr>
		<tr>
			<td>Jerry</td>
			<td>jerry@sohu.com</td>
			<td>8000</td>
			<td><a href="deleteEmp?id=002">Delete</a></td>
		</tr>
		<tr>
			<td>Bob</td>
			<td>bob@tom.com</td>
			<td>10000</td>
			<td><a href="deleteEmp?id=003">Delete</a></td>
		</tr>
	</table>

</body>
</html>
